/**
 * Created by 15183 on 2017/9/19.
 */
$(function() {
	var ddata = {
		withdraw_type: 1
	};
	var ddatb = {
		withdraw_type: 2
	};

	var gilr_columns_x = [ //女待提现
		{ //时间
			data: "withdraw_time"
		},
		{ //昵称
			data: "nick"
		},
		{ //提现方式
			data: function(obj) {
				if(obj.withdraw_type == "支付宝提现") {
					$withdraw_account_a = "";
					$withdraw_account_a = "<span>" + obj.withdraw_type + "</span>";
					return $withdraw_account_a
				}
				if(obj.withdraw_type == "银行卡提现") {
					$withdraw_account_b = "";
					$withdraw_account_b = "<span>" + obj.bank_name + "</span>";
					return $withdraw_account_b
				}
			}
		},
		{ //   账号
			data: function(obj) {
				$withdraw = "";
				$withdraw = "<span>" + obj.withdraw_account + "</span>";
				return $withdraw
			}
		},
		{ //原有金额
			data: function(obj) {
				$balance = "";
				$balance = "<span>" + obj.balance + "</span>";
				return $balance
			}
		},
		{ //提现金额
			data: function(obj) {
				var yu = parseInt(obj.amount);
				var shou = parseInt(obj.fee);
				var shiji = yu + shou;
				$amount = "";
				$amount = "<span>" + shiji + "</span>";
				return $amount
			}
		},
		{ //账号剩余金额
			data: function(obj) {
				var yu = parseInt(obj.amount);
				var shou = parseInt(obj.fee);
				var shiji = yu + shou;
				var zon = parseInt(obj.balance);
				var shenyu = zon - shiji
				$surplus = "";
				$surplus = "<span>" + shenyu + "</span>";
				return $surplus
			}
		},
		{ //到账金额
			data: function(obj) {

				$account = "";
				$account = "<span>" + obj.amount + "</span>";
				return $account
			}
		},

		{ // 收益
			data: "fee"
		},
		{
			data: function(obj) {
				$shenhe1 = "<a data-toggle='modal' data-target='#Cash'  class='btn btn-primary Cosa_return'>同意提现<span style='display:none'>" + obj.girl_withdraw_id + "</span></a>";
				return $shenhe1;
			}
		}
	];
	var gilr_columns_y = [ //女已提现
		{ //时间
			data: "withdraw_time"
		},
		{ //昵称
			data: "nick"
		},
		{ //提现方式
			data: function(obj) {
				if(obj.withdraw_type == "支付宝提现") {
					$withdraw_account_a = "";
					$withdraw_account_a = "<span>" + obj.withdraw_type + "</span>";
					return $withdraw_account_a
				}
				if(obj.withdraw_type == "银行卡提现") {
					$withdraw_account_b = "";
					$withdraw_account_b = "<span>" + obj.bank_name + "</span>";
					return $withdraw_account_b
				}
			}
		},
		{ //   账号
			data: function(obj) {
				$withdraw = "";
				$withdraw = "<span>" + obj.withdraw_account + "</span>";
				return $withdraw
			}
		},
		{ //原有金额
			data: function(obj) {
				$balance = "";
				$balance = "<span>" + obj.balance + "</span>";
				return $balance
			}
		},
		{ //提现金额
			data: function(obj) {
				var yu = parseInt(obj.amount);
				var shou = parseInt(obj.fee);
				var shiji = yu + shou;
				$amount = "";
				$amount = "<span>" + shiji + "</span>";
				return $amount
			}
		},
		{ //账号剩余金额
			data: function(obj) {
				var yu = parseInt(obj.amount);
				var shou = parseInt(obj.fee);
				var shiji = yu + shou;
				var zon = parseInt(obj.balance);
				var shenyu = zon - shiji
				$surplus = "";
				$surplus = "<span>" + shenyu + "</span>";
				return $surplus
			}
		},
		{ //到账金额
			data: function(obj) {

				$account = "";
				$account = "<span>" + obj.amount + "</span>";
				return $account
			}
		},

		{ // 收益
			data: "fee"
		},
		{ //订单号
			data: function(obj) {
				$dindang = "";
				$dindang = "<span>" + obj.transfer_order + "</span>";
				return $dindang
			}
		},
		{ //备注
			data: function(obj) {
				var str = obj.remarks; //原始字符串
				var s = str; //要展示的字符串
				if(str.length > 10) {
					s = str.substring(0, 10) + "...";
					$dindang = "";
					$dindang = "<div style='position:relative'>" +
						"<span class='xcontent'>" + s + "</span>" +
						"<div style='display:none;position:absolute'>" + obj.remarks + "</div>" +
						"</div>";
					return $dindang
				} else {
					$dindang = "";
					$dindang = "<div><span>" + obj.remarks + "</span><div style='display:none'>" + obj.remarks + "</div></div>";
					return $dindang
				}

			}

		},
		{
			data: function(obj) {
				$cz = "";
				$cz = "<a data-toggle='modal' data-target='#remark' class='btn btn-primary xiugaib'>修改备注<span style='display:none'>" + obj.girl_withdraw_id + "</span></a>"
				return $cz
			}
		}

	];
	$("#tixianguanl").click(function() { // 在点击提现管理的时候就  加载  女生提现数据
		$("#tixi_1").text("女生提现管理");
		Data_table("#example14", address1 + "/admin/withdraw/pendingGirl", gilr_columns_x, false, ddata,5);

		Data_table("#example15", address1 + "/admin/withdraw/pendingGirl", gilr_columns_y, false, ddatb,5);

		//点击同意提现
		$("#example14").ajaxComplete(function() {
			var withdraw_id = "";
			$(".Cosa_return").unbind("click").on("click", function() {
				withdraw_id = $(this).find("span").text();
				$("#Cash_bec").val("");
				$(".cos_qud").unbind("click").on("click", function() {
					var dingdanhao = $("#dingdan").val();
					var xiangxi = $("#Cash_bec").val();
					var tixTJ = {
						"transfer_order": dingdanhao,
						"remarks": xiangxi,
						"girl_withdraw_id": withdraw_id
					};

					TJ_ajax_fahuo(address1 + "/admin/withdraw/girlProcessed", tixTJ, "#Cash", "#example14")
				})

			});
			$(".xcontent").parent().parent().hover(function() {

				$(this).find($(".xcontent")).css("opacity", 0);
				$(this).find($(".xcontent")).next().css({
					"display": "block",
					"top": "-10px",
					"background": "white",
					"z-index": 9999
				});
			}, function() {
				$(this).find($(".xcontent")).css("opacity", 1);
				$(this).find($(".xcontent")).next().css("display", "none")
			})

		});
		//点击修改备注
		$("#example15").ajaxComplete(function() {
			var withdraw_id = "";
			$(".xiugaib").unbind("click").on("click", function() {
				withdraw_id = $(this).find("span").text();
				var ordmessag = $(this).parent().prev().find("div").find("div").html();
				$("#beizhu_con").val(ordmessag);
				$(".remark_tj").unbind("click").on("click", function() {
					var xiangxi = $("#beizhu_con").val();
					var beizhu22 = {
						"remarks": xiangxi,
						"girl_withdraw_id": withdraw_id
					};
					console.log(beizhu22)
					TJ_ajax_fahuo(address1 + "/admin/withdraw/changeGirlProcessed", beizhu22, "#remark", "#example15")
				})

			});

		});

	})

	$("#gilr_pay").click(function() { // 在点击女生提现管理的时候 加载 女生提现数据
		$("#tixi_1").text("女生提现管理");
		Data_table("#example14", address1 + "/admin/withdraw/pendingGirl", gilr_columns_x, false, ddata,5);

		Data_table("#example15", address1 + "/admin/withdraw/pendingGirl", gilr_columns_y, false, ddatb,5);

		//点击同意提现
		$("#example14").ajaxComplete(function() {
			var withdraw_id = "";
			$(".Cosa_return").unbind("click").on("click", function() {
				withdraw_id = $(this).find("span").text();
				$("#Cash_bec").val("");
				$(".cos_qud").unbind("click").on("click", function() {
					var dingdanhao = $("#dingdan").val();
					var xiangxi = $("#Cash_bec").val();
					var tixTJ = {
						"transfer_order": dingdanhao,
						"remarks": xiangxi,
						"girl_withdraw_id": withdraw_id
					};

					TJ_ajax_fahuo(address1 + "/admin/withdraw/girlProcessed", tixTJ, "#Cash", "#example14")
				})

			});
			$(".xcontent").parent().parent().hover(function() {

				$(this).find($(".xcontent")).css("opacity", 0);
				$(this).find($(".xcontent")).next().css({
					"display": "block",
					"top": "-10px",
					"background": "white",
					"z-index": 9999
				});
			}, function() {
				$(this).find($(".xcontent")).css("opacity", 1);
				$(this).find($(".xcontent")).next().css("display", "none")
			})

		});

		//点击修改备注
		$("#example15").ajaxComplete(function() {
			var withdraw_id = "";
			$(".xiugaib").unbind("click").on("click", function() {
				withdraw_id = $(this).find("span").text();
				var ordmessag = $(this).parent().prev().find("div").find("div").html();
				$("#beizhu_con").val(ordmessag);
				$(".remark_tj").unbind("click").on("click", function() {
					var xiangxi = $("#beizhu_con").val();
					var beizhu23 = {
						"remarks": xiangxi,
						"girl_withdraw_id": withdraw_id
					};
					console.log(beizhu23)
					TJ_ajax_fahuo(address1 + "/admin/withdraw/changeGirlProcessed", beizhu23, "#remark", "#example15")
				})

			});

		});

	});

	var boy_columns_x = [ //男 待提现
		{ //时间
			data: "withdraw_time"
		},
		{ //昵称
			data: "nick"
		},
		{ //提现方式
			data: function(obj) {
				if(obj.withdraw_type == "支付宝提现") {
					$withdraw_account_a = "";
					$withdraw_account_a = "<span>" + obj.withdraw_type + "</span>";
					return $withdraw_account_a
				}
				if(obj.withdraw_type == "银行卡提现") {
					$withdraw_account_b = "";
					$withdraw_account_b = "<span>" + obj.bank_name + "</span>";
					return $withdraw_account_b
				}
			}
		},
		{ //   账号
			data: function(obj) {
				$withdraw = "";
				$withdraw = "<span>" + obj.withdraw_account + "</span>";
				return $withdraw
			}
		},
		{ //原有金额
			data: function(obj) {
				$balance = "";
				$balance = "<span>" + obj.balance + "</span>";
				return $balance
			}
		},
		{ //提现金额
			data: function(obj) {
				var yu = parseInt(obj.amount);
				var shou = parseInt(obj.fee);
				var shiji = yu + shou;
				$amount = "";
				$amount = "<span>" + shiji + "</span>";
				return $amount
			}
		},
		{ //账号剩余金额
			data: function(obj) {
				var yu = parseInt(obj.amount);
				var shou = parseInt(obj.fee);
				var shiji = yu + shou;
				var zon = parseInt(obj.balance);
				var shenyu = zon - shiji
				$surplus = "";
				$surplus = "<span>" + shenyu + "</span>";
				return $surplus
			}
		},
		{ //到账金额
			data: function(obj) {

				$account = "";
				$account = "<span>" + obj.amount + "</span>";
				return $account
			}
		},

		{ // 收益
			data: "fee"
		},
		{
			data: function(obj) {
				$shenhe1 = "<a data-toggle='modal' data-target='#Cash'  class='btn btn-primary Cosa_return'>同意提现<span style='display:none'>" + obj.boy_withdraw_id + "</span></a>";
				return $shenhe1;
			}
		}
	];

	var boy_columns_y = [ //男已提现
		{ //时间
			data: "withdraw_time"
		},
		{ //昵称
			data: "nick"
		},
		{ //提现方式
			data: function(obj) {
				if(obj.withdraw_type == "支付宝提现") {
					$withdraw_account_a = "";
					$withdraw_account_a = "<span>" + obj.withdraw_type + "</span>";
					return $withdraw_account_a
				}
				if(obj.withdraw_type == "银行卡提现") {
					$withdraw_account_b = "";
					$withdraw_account_b = "<span>" + obj.bank_name + "</span>";
					return $withdraw_account_b
				}
			}
		},
		{ //   账号
			data: function(obj) {
				$withdraw = "";
				$withdraw = "<span>" + obj.withdraw_account + "</span>";
				return $withdraw
			}
		},
		{ //原有金额
			data: function(obj) {
				$balance = "";
				$balance = "<span>" + obj.balance + "</span>";
				return $balance
			}
		},
		{ //提现金额
			data: function(obj) {
				$amount = "";
				$amount = "<span>" + obj.amount + "</span>";
				return $amount
			}
		},
		{ //账号剩余金额
			data: function(obj) {
				var yu1 = obj.balance;
				var ti1 = obj.amount;
				var shenyu = yu1 - ti1;
				$surplus = "";
				$surplus = "<span>" + shenyu + "</span>";
				return $surplus
			}
		},
		{ //到账金额
			data: function(obj) {
				var yu = obj.amount;
				var shou = obj.fee;
				var shiji = yu - shou;
				$account = "";
				$account = "<span>" + shiji + "</span>";
				return $account
			}
		},

		{ // 收益
			data: "fee"
		},
		{ //订单号
			data: function(obj) {
				$dindang = "";
				$dindang = "<span>" + obj.transfer_order + "</span>";
				return $dindang
			}
		},
		{ //备注
			data: function(obj) {
				var str = obj.remarks; //原始字符串
				var s = str; //要展示的字符串

				if(str.length > 10) {
					s = str.substring(0, 10) + "...";

					$dindang = "";
					$dindang = "<div style='position:relative'>" +
						"<span class='xcontent'>" + s + "</span>" +
						"<div style='display:none;position:absolute'>" + obj.remarks + "</div>" +
						"</div>";
					$(".xcontent").parent().parent().hover(function() {
						$(this).find($(".xcontent")).css("opacity", 0);
						$(this).find($(".xcontent")).next().css({
							"display": "block",
							"top": "-10px",
							"background": "white",
							"z-index": 9999
						});
					}, function() {
						$(this).find($(".xcontent")).css("opacity", 1);
						$(this).find($(".xcontent")).next().css("display", "none")
					})
					return $dindang
				} else {
					$dindang = "";
					$dindang = "<div><span>" + obj.remarks + "</span><div style='display:none'>" + obj.remarks + "</div></div>";
					return $dindang
				}

			}

		},
		{
			data: function(obj) {
				$cz = "";
				$cz = "<a data-toggle='modal' data-target='#remark' class='btn btn-primary xiugaib'>修改备注<span style='display:none'>" + obj.boy_withdraw_id + "</span></a>"
				return $cz
			}
		}
	];
	$("#boy_pay").click(function() {
		$("#tixi_1").text("男生生提现管理");
		Data_table("#example14", address1 + "/admin/withdraw/pendingBoy", boy_columns_x, false, ddata,5);
		Data_table("#example15", address1 + "/admin/withdraw/pendingBoy", boy_columns_y, false, ddatb,5);
		//点击同意提现
		$("#example14").ajaxComplete(function() {
			var withdraw_id = "";
			$(".Cosa_return").unbind("click").on("click", function() {
				withdraw_id = $(this).find("span").text();
				$("#Cash_bec").val("");
				$(".cos_qud").unbind("click").on("click", function() {
					var dingdanhao = $("#dingdan").val();
					var xiangxi = $("#Cash_bec").val();
					var tixTJ = {
						"transfer_order": dingdanhao,
						"remarks": xiangxi,
						"boy_withdraw_id": withdraw_id
					};

					TJ_ajax_fahuo(address1 + "/admin/withdraw/boyProcessed", tixTJ, "#Cash", "#example14")
				})

			});
			$(".xcontent").parent().parent().hover(function() {

				$(this).find($(".xcontent")).css("opacity", 0);
				$(this).find($(".xcontent")).next().css({
					"display": "block",
					"top": "-10px",
					"background": "white",
					"z-index": 9999
				});
			}, function() {
				$(this).find($(".xcontent")).css("opacity", 1);
				$(this).find($(".xcontent")).next().css("display", "none")
			})

		});
		//点击修改备注
		$("#example15").ajaxComplete(function() {
			var withdraw_id = "";
			$(".xiugaib").unbind("click").on("click", function() {
				withdraw_id = $(this).find("span").text();
				var ordmessag = $(this).parent().prev().find("div").find("div").html();
				$("#beizhu_con").val(ordmessag);
				$(".remark_tj").unbind("click").on("click", function() {
					var xiangxi = $("#beizhu_con").val();
					var beizhu23 = {
						"remarks": xiangxi,
						"boy_withdraw_id": withdraw_id
					};
					console.log(beizhu23)
					TJ_ajax_fahuo(address1 + "/admin/withdraw/changeBoyProcessed", beizhu23, "#remark", "#example15")
				})

			});

		});

	});

});